package design_mode.策略模式.打折算法;

public class CashReturn extends CashSuper{
    private double moneyCondition = 0d;  // 返利条件
    private double moneyReturn = 0d;  // 返利值

    public  CashReturn(double moneyCondition, double moneyReturn) {
        this.moneyCondition = moneyCondition;
        this.moneyReturn = moneyReturn;
    }

    @Override
    public double acceptCash(double price, int num) {
        double reslut = price * num;
        if (moneyCondition > 0 && reslut >= moneyCondition) {
            reslut = reslut - Math.floor(reslut / moneyCondition) * moneyReturn;
        }
        return reslut;
    }
}
